﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CorporateGym.DAL;


namespace BLL.Entities
{
    public class Malfunction
    {
        public int Id { get; set; }
        public string Subject { get; set; }
        public string Description { get; set; }
        public DateTime CreatedTime { get; set; }
        public DateTime? ClosedTime { get; set; }
        public int CreatorId { get; set; }
        public int CloserId { get; set; }

        public static Malfunction CreateFromRow(CorporateGymDB.MalfunctionRow i_Row)
        {
            return new Malfunction { 
                Id = i_Row.MalfunctionId,
                Subject = i_Row.Name,
                Description = i_Row.Description,
                CreatedTime = i_Row.CreateTime,
                ClosedTime = i_Row.IscloseTimeNull() ? null : (DateTime?)i_Row.closeTime,
                CreatorId = i_Row.CreatorId,
                CloserId = i_Row.CloserId
            };
        }
    }
}
